<?php
require_once '../utils/common.php';
require_once '../Config.php';
$conn = mysql_connect ( host, username, password );
if (! $conn) {
	die ( "连接失败" . mysql_error () );
}
mysql_select_db ( db, $conn );
$flag = $_REQUEST['flag'];
if($flag == "add"){
	$image = upload("image");
	$content = $_POST["content"];
	$sql = "set names utf8";
	mysql_query($sql);
	$sql = "insert into j_tab_frist(image, content) values ('".$image."','".$content."')";
	mysql_query($sql);
	mysql_close($conn);
	echo "<script>alert('添加成功!');self.location='FristManager.php';</script>";
}else if($flag == 'del'){
	$id = $_REQUEST['id'];
	$sql = "delete from j_tab_frist where id=".$id;
	mysql_query($sql);
	mysql_close($conn);
	echo "<script language=\"JavaScript\">\r\n";
	echo " alert(\"删除成功\");\r\n";
	echo " history.back();\r\n";
	echo "</script>";
	exit;
}else if($flag == 'update'){
	$id = $_REQUEST['id'];
	$image = upload("image");
	$content = $_POST["content"];
	$sql = "set names utf8";
	mysql_query($sql);
	if($image == ""){
		$sql = "update j_tab_frist set content='".$content."' where id=".$id;
	}else{
		$sql = "update j_tab_frist set content='".$content."',image='".$image."' where id=".$id;
	}
	
	mysql_query($sql);
	mysql_close($conn);
	echo "<script>alert('修改成功!');self.location='FristManager.php';</script>";
}



?>